<template>
    <view class="box">
        <!-- main -->
        <view class="main" :style="{paddingBottom: unipx + 'px'}">
            <view v-if="show == 0">
                <index @toClassify="toClassify"></index>
            </view>
            <view v-if="show == 1">
                <classify :classifyId="classifyId"></classify>
            </view>
       <!--     <view v-if="show == 2">
                <cart ref="cart"></cart>
            </view> -->
<!--            <view v-if="show == 3">
                <user></user>
            </view> -->
        </view>
        <!-- main e -->
        <!-- 自定义tabbar -->
        <!-- <view class="tabbar">
            <tabbar ref="tabbar" @clicktabindex="gettabindx"></tabbar>
        </view> -->
        <!-- 自定义tabbar e -->
        <tabBar
            ref="tabbar"
            @clicktabindex="gettabindx"
            active-color="#1bc078"
            inactive-color="#cccccc"
        ></tabBar>
    </view>
</template>

<script>
    // 主要展示的内容组件
    import index from '../index/index'
    // 分类页面
    import classify from '../list/classify'
    // 用户购物车
    import cart from '../list/cart'
    //用户信息
    import user from '../list/user'
    
    import tabbar from '../../../tabBar/tabBar.vue'

    export default {
        components: {
            index,
            classify,
            cart,
            user,
            tabbar
        },
        data() {
            return {
                show: 0,
                tabbarsarr: [{
                    name: '首页',
                    img: '../static/img/navimg/Tab-icon-01@3x.png',
                    activeimg: '../static/img/navimg/Tab-icon-Active-01@3x.png'
                }, {
                    name: '分类',
                    img: '../static/img/navimg/sc-Tab-icon-02@3x.png',
                    activeimg: '../static/img/navimg/sc-Tab-icon-Active-02@3x.png'
                }
				// , {
    //                 name: '购物车',
    //                 img: '../static/img/navimg/sc-Tab-icon-03@3x.png',
    //                 activeimg: '../static/img/navimg/sc-Tab-icon-Active-03@3x.png'
    //             },{
    //                 name: '用户',
    //                 img: '../static/img/navimg/Tab-icon-04@3x.png',
    //                 activeimg: '../static/img/navimg/Tab-icon-Active-04@3x.png'
    //             }
                ],
                unipx: 0,
                classifyId: 0,
            };
        },
        onLoad(options) {
            this.unipx = uni.upx2px(120);
            if(!this.$u.test.isEmpty(options)) {
                this.show = options.show
                this.$store.commit('changeShopActive', options.show)
            }
        },
        onShow() {
            if(this.$store.state.isOrder == 1) {
                this.$refs.cart._postGetCartList();
                this.$store.commit('setOrder', 1);
            }
        },
        methods: {
            gettabindx() {
                this.show = this.$store.state.shopActive
            },
            toClassify(id) {
                this.show = 1;
                this.$refs.tabbar.clicktabbars(1);
                this.classifyId = id;
            },
        }
    }
</script>

<style lang="scss" scoped>
    .box {
        
    }
    
    .main {

    }
</style>
